package cn.ekuma.epos.datalogic.define.dao.crm.contract;

import cn.ekuma.data.dao.BaseDAO;
import cn.ekuma.epos.datalogic.define.dao.shard.StateFollowDAOHelper;
import cn.ekuma.epos.db.table.crm.contract.I_ContractFollow;
import cn.ekuma.epos.db.table.shard.I_StateFollowTable;

import com.openbravo.bean.crm.contract.Contract;
import com.openbravo.bean.crm.contract.ContractFollow;
import com.openbravo.data.basic.BasicException;
import com.openbravo.data.loader.DataRead;
import com.openbravo.data.loader.DataWrite;
import com.openbravo.data.loader.Datas;
import com.openbravo.data.loader.I_Session;
import com.openbravo.data.loader.TableDefinition;
import com.openbravo.data.model.Field;
import com.openbravo.format.Formats;

public class ContractFollowDAO extends BaseDAO<ContractFollow> {

	public ContractFollowDAO(I_Session s) {
		super(s);
	}

	@Override
	public TableDefinition getTable() {
		TableDefinition table=StateFollowDAOHelper.getTable(s, "CONTRACTFOLLOW");
		table.addField(new Field(I_ContractFollow.STATEOBJECTID, Datas.STRING, Formats.STRING,Contract.class));
		return table;
	}

	@Override
	public void writeInsertValues(DataWrite dp, ContractFollow obj)
			throws BasicException {
		StateFollowDAOHelper.writeInsertValues(dp, obj, 1);
		dp.setString(I_StateFollowTable.COLUMN_COUNT+1,obj.getStateObjectId());
		
	}

	@Override
	public Class getSuportClass() {
		return ContractFollow.class;
	}

	@Override
	public ContractFollow readValues(DataRead dr, ContractFollow obj)
			throws BasicException {
		StateFollowDAOHelper.readValues(dr, obj, 1);
		obj.setStateObjectId(dr.getString(I_StateFollowTable.COLUMN_COUNT+1));
		return obj;
	}

}
